<template>
  <nav class="vertical-nav" :class="{ 'is-collapsed': isCollapsed }">
    <div class="collapse-btn" @click="toggleCollapse">
      <el-icon><Menu /></el-icon>
    </div>
    <ul class="nav-list">
      <li><router-link to="/index/home"><el-icon><HomeFilled /></el-icon><span>首页</span></router-link></li>
      <li><router-link to="/hotel"><el-icon><OfficeBuilding /></el-icon><span>酒店</span></router-link></li>
      <li><router-link to="/scenic"><el-icon><Ticket /></el-icon><span>景点</span></router-link></li>
      <li><router-link to="/tuan"><el-icon><Suitcase /></el-icon><span>跟团游</span></router-link></li>
      <li><router-link to="/map"><el-icon><MapLocation /></el-icon><span>旅游地图</span></router-link></li>
      <li><router-link to="/tc"><el-icon><Food /></el-icon><span>特色产品</span></router-link></li>
      <li><router-link to="/user/info"><el-icon><User /></el-icon><span>个人中心</span></router-link></li>
      <li><router-link to="/msg"><el-icon><User /></el-icon><span>消息推送</span></router-link></li>
    </ul>
  </nav>
</template>

<script setup>
import { ref, defineEmits } from 'vue';
import {
  HomeFilled,
  Suitcase,
  OfficeBuilding,
  Promotion,
  Ticket,
  MagicStick,
  Service,
  User,
  Menu,
  Van,
  Location,
  MapLocation
} from '@element-plus/icons-vue';

const isCollapsed = ref(false);
const emit = defineEmits(['toggle-collapse']);

const toggleCollapse = () => {
  isCollapsed.value = !isCollapsed.value;
  emit('toggle-collapse', isCollapsed.value);
};
</script>

<style scoped>
.vertical-nav {
  width: 180px;
  background-color: #fff;
  height: 100%;
  padding-top: 10px;
  transition: width 0.3s ease;
  box-sizing: border-box;
}

.vertical-nav.is-collapsed {
  width: 64px;
}

.collapse-btn {
  display: flex;
  align-items: center;
  padding: 10px 23px;
  font-size: 20px;
  color: #555;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 10px;
  transition: padding 0.3s ease;
}

.vertical-nav.is-collapsed .collapse-btn {
  padding: 10px 0;
  justify-content: center;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 3px solid transparent;
  overflow: hidden;
  white-space: nowrap;
}
.nav-list a {
  display: flex;
  align-items: center;
  padding: 14px 24px;
  font-size: 16px;
  color: #333;
  text-decoration: none;
  transition: all 0.2s ease;
}
.nav-list a .el-icon {
  margin-right: 12px;
  font-size: 20px;
  transition: margin 0.3s ease;
}
.nav-list a:hover {
  background-color: #f0f8ff;
  color: #0086f6;
}
.nav-list a.router-link-exact-active,
.nav-list a.router-link-active {
  background-color: #eaf5ff;
  color: #0086f6;
  font-weight: 600;
  border-left-color: #0086f6;
}

.vertical-nav.is-collapsed .nav-list a {
  justify-content: center;
}

.vertical-nav.is-collapsed .nav-list a .el-icon {
  margin-right: 0;
}

.vertical-nav.is-collapsed .nav-list a span {
  display: none;
}
</style> 